/**
 * 文章请求模块
 */
import request from '@/utils/request'

/**
 * 获取文章列表
 */
export const getArticles = (params) => {
  return request({
    method: 'GET',
    url: '/app/v1_1/articles',
    // params 选项用来配置 Query 参数
    params
  })
}

// 获取文章详情
export const getArticleDetailAjax = (article_id) => {
  return request({
    url: '/app/v1_0/articles/' + article_id,
    method: 'GET'
  })
}


// 文章的收藏
export const addCollectAjax = (target) => {
  return request({
    url: '/app/v1_0/article/collections',
    method: 'POST',
    data: {
      target
    }
  })
}

// 取消文章的收藏
export const deleteCollectAjax = (target) => {
  return request({
    url: '/app/v1_0/article/collections/' + target,
    method: 'DELETE'
    // params: {  只有get请求可以通过这个params传参， delete请求是不行；只能去url路径里面拼接
    //   target
    // }
  })
}


// 对文章点赞
export const addLikingAjax  = (target) => {
  return request({
    // url里面不能有其他特殊字符， 空格会编码为 %20  汉字也会被utf-8这个编码格式转换
    url: '/app/v1_0/article/likings',
    method: 'POST',
    data: {
      target
    }
  })
}

// 取消对文章点赞
export const deleteLikingAjax = (target) => {
  return request({
    url: '/app/v1_0/article/likings/' + target,
    method: 'DELETE'
  })
}